package com.example.demo.email.controller;

import com.example.demo.email.service.EmailService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.mail.MessagingException;

/**
 * @Author: zjq
 * @Date: create in 2024/1/3 18:17
 */
@Api(tags = {"邮件发送"})
@RestController
@RequestMapping("/email")
public class EmailController {

    @Autowired
    private EmailService emailService;

    @ApiOperation(value = "邮件发送")
    @GetMapping("sendEmail")
    public void sendEmail(String email, String code) {
        try {
            emailService.sendMail(email, code);
        } catch (MessagingException e) {
            e.printStackTrace();
        }
    }
}
